package no.ntnu.idi.deid.statistical.tfidf;

import java.io.File;
import java.util.TreeMap;

import no.ntnu.idi.deid.documentunits.Document;
import no.ntnu.idi.deid.preprocessor.Documents;
import no.ntnu.idi.deid.preprocessor.wordcount.CountManager;
import no.ntnu.idi.deid.preprocessor.wordcount.Entity;

public class SentenceDocumentFrequency extends DocumentFrequency {

	public SentenceDocumentFrequency(Documents documents) {
		super(documents);
	}
	
	public SentenceDocumentFrequency(File file) {
		super(file);
	}

	@Override
	protected void generateMap(Documents documents) {
			TreeMap<String, Integer> tfMap = new TreeMap<String, Integer>();
			for (Document doc : documents) {
				CountManager scm = doc.getSentenceCountManager();				
				for (Entity word : scm.getSortedWords()) {
					insert(word.getString(), tfMap);
				}
			}
			generateTfIdfMap(tfMap);
		}	
}
